# -*- coding: utf-8 -*-

import MySQLdb


conn = MySQLdb.connect(host="101.200.76.133",user="root",passwd="Abcd1234",port=3306,db="dls_app",charset="utf8")

def insertQiubai(spider_id,format,content,image,image_size,pic_url,low_url,high_url,user):
    print (spider_id,format,content,image,image_size,pic_url,low_url,high_url,user)
    cur = conn.cursor()
    cur.execute("insert into t_qiubai(spider_id,format,content,image,image_size,pic_url,low_url,high_url,user) values(%s,%s,%s,%s,%s,%s,%s,%s,%s)",(spider_id,format,content,image,image_size,pic_url,low_url,high_url,user))
    conn.commit()
    cur.close()

def getLastId():
    cur = conn.cursor()
    sql = "select value from t_sys_conf where config='qb_lastid' order by id desc limit 0,1"
    rs = cur.execute(sql)
    row = cur.fetchone()
    return int(row[0])
    
def addLastId(num):
    cur = conn.cursor()
    sql = "insert into t_sys_conf(config,value) values(%s,%s)"
    rs = cur.execute(sql,("qb_lastid",num ) )
    conn.commit()
    print "###",rs,"###"
    return rs
